package jp.yvn.game.shooting.element;

import android.graphics.Point;

/**
 * 弾幕オブジェクトクラス
 * 
 * @author Yvn_pq
 */
public class SpiralBulletEntity extends CircleBulletEntity {

	/** 移動スピード */
	private final float mBuletSpeed = 0.5f;

	private int mDelay = 1; // 螺旋の弾幕ごとの間の遅延

	private float mRounds = 1; // 螺旋の回る回数

	private int mCurrent = 0;

	private int mDelayCount = 0;

	/**
	 * コンストラクタ
	 * 
	 * @param centerX
	 * @param centerY
	 * @param viewSize
	 * @param number
	 * @param delay
	 * @param rounds
	 * @param clockwise
	 */
	public SpiralBulletEntity(float centerX, float centerY, Point viewSize, int number, int delay, float rounds, boolean clockwise) {
		super(centerX, centerY, viewSize, number);
		mRounds = rounds;
		mDelay = delay;
		if (mDelay < 1) {
			mDelay = 1;
		}
		if (mRounds <= 0) {
			mRounds = 1;
		}
		angle *= mRounds;
		if (clockwise) {
			angle = -angle;
		}
	}

	/**
	 * アニメーションを設定します
	 */
	@Override
	public void setAnimation() {
		for (int i = 0; i < mCurrent; i++) {
			childBulletPoint[i].x += mBuletSpeed * Math.cos(i * angle);
			childBulletPoint[i].y -= mBuletSpeed * Math.sin(i * angle);
		}
		mDelayCount++;
		if (mDelayCount > mDelay) {
			mDelayCount = 0;
			if (mCurrent < childBulletNumber) {
				mCurrent++;
			}
		}
	}
}
